home *** CD-ROM | disk | FTP | other *** search
- /* TEST program - read XREF0001.$$$ & display it */
-
- #include <stdio.h>
- FILE *fp;
- int reclen;
- char recin[200];
- int ef=1;
-
- main()
- { if((fp=fopen("XREF0001.$$$","rb"))==NULL)abort("no work file\n");
- while(ef){
- if(wgetr(fp,&reclen,2)==EOF)ef=0; /* get reclen */
- else { if(wgetr(fp,recin,reclen)==EOF)ef=0; } /* get record */
- wunpack(recin);
- }
- fclose(fp);
- }
-
-
- wgetr(fptr,buf,len) /* read <len> bytes into <buf> */
- FILE *fptr;
- unsigned char *buf;
- int len;
- { int j;
- while(len--){
- if((j=fgetc(fptr))==EOF)return j;
- *buf++=j;
- }
- }
-
- wunpack(ok) /* get packed key as struct BUFR */
- char *ok;
- { char *wunpackey(), kp[200], *t;
- int ref;
- ok=wunpackey(ok,kp,31); /* key 1*/
- ok=wunpackey(ok,kp+31,31); /* key 2*/
- ok=wunpackey(ok,kp+62,8); /* key 3 (EOS will be there) */
- t=&ref; /* get reference */
- *t++=*ok++;
- *t++=*ok++;
- printf("%s %4d\n",kp,ref);
- return (0);
- }
-
- char *wunpackey(kp,k,len) /* convert key string->fixed length*/
- char *kp; /* buffer in */
- char k[]; /* new key */
- int len; /* max length of key */
- { int i=0;
- while(*kp)k[i++]=*kp++; /* move in key */
- while(i<len)k[i++]=' '; /* pad with spaces to size */
- k[i]='\0'; /* mark end of key (in case last one) */
- return ++kp;
- }
- e code */
- if(bdos(OPENF,&mfcb_))re